<template>
  <div class="zqty_bodys" style="padding-top:20px;border:0px solid blue;" :style="{'height':(divAutoHeight-140)+'px','width':(divAutoWidth - 150)+'px'}" >
    <div  style="border:0px solid green;"  :style="{'height':(divAutoHeight-180)+'px','width':(divAutoWidth-170)+'px','margin-left':'20px'}" >
      <!-- 查询 -->
      <el-popover placement="bottom-start" trigger="click">
        <el-form :inline="true" :model="search" label-width="75px" class="search-panle">
          <el-form-item label="客户档案号"><el-input v-model="search.cardid" /></el-form-item>
          <el-form-item label="客户姓名"><el-input v-model="search.name" /></el-form-item>
          <el-form-item label="创建时间"><el-date-picker v-model="search.time" type="daterange" range-separator="至" start-placeholder="开始时间" end-placeholder="结束时间" align="right"/></el-form-item>
          <el-button type="primary" @click="searchData">提交</el-button>
        </el-form>
        <el-button slot="reference" type="primary">查询</el-button>
      </el-popover>
      <!-- 列表 -->
      <el-tabs v-model="mainActiveName" @tab-click="syschRecodeStatus">
        <el-tab-pane label="待接诊" name="0"/>
        <el-tab-pane label="接诊中" name="1"/>
        <el-tab-pane label="已接诊" name="2" />
      </el-tabs>
      <div class="divTop" style="border:0px solid red;" :style="{'height':(divAutoHeight-270)+'px','overflow-y':'auto'}">
        <div v-for="item in tableData" class="showDataLi" :key="item.id">
          <div class="showDataTop">
            <div class="showDataTopLeft">
              <img v-if="item.providerInfo.photo" :src="'data:image/png;base64,'+ item.providerInfo.photo" class="showDataImg"/>
            </div>
            <div class="showDataTopCenter">
              <div style="width:99%;height:30px;">
                <div style="font-size:16px;font-weight:bolder;float:left;">{{item.providerNoName}}</div>
                  <div style="font-size:13px;color:gray;float:left;margin-left:5px;margin-top:3px;">{{item.providerInfo.sex === '1'? '男':'女'}}&nbsp;{{item.providerInfo.age}}岁</div>
                </div>
                <div style="width:99%;height:70px;font-size:13px;color:gray;">
                  <div>登记号：{{item.registerNo}}</div>
                  <div style="margin-top:3px;">病案号：{{item.providerInfo.cardId}}</div>
                  <div style="margin-top:3px;">接诊医生：{{item.treatmentUserName}}</div>
                  <div style="margin-top:3px;">接诊时间：{{timestampToTime(item.treatmentDate,'yy-mm-dd hh:mm:ss')}}</div>
                </div>
              </div>
              <div class="showDataTopRight">
                <div v-if="item.currentStatus === 0 " class="statusGreen">待接诊</div>
                <div class="statusGreen" v-else-if="item.currentStatus === 1 ">接诊中</div>
                <div v-else-if="item.currentStatus === 2" class="statusGray" >已接诊</div> 
                <div v-if="item.state === -1" class="statusGray"> 未下发</div>
                <div v-else-if="item.state === 0" class="statusGray"> 待检测</div> 
                <div v-else-if="item.state === 1" class="statusGray"> 已检测</div>
              </div>
              <div class="showDataFoot" @click="callToWz(item.id)" v-if="item.currentStatus === 0 ">叫号</div>
              <div class="showDataFoot" @click="updateDialog(item)" v-else-if="item.currentStatus === 1 ">接诊</div>
              <div class="showDataFoot" @click="updateDialog(item)"  v-else-if="item.currentStatus === 2">详情</div>
            </div>
          </div>
        </div>
      <el-pagination background @size-change="handleSizeChange" @current-change="handleCurrentChange" :current-page="pagination.currentPage" :page-sizes="[10, 15,20, 25,30,50, 100]" :page-size="pagination.pageSize" layout="total, sizes, prev, pager, next, jumper" :total="pagination.total"/>
      <!-- 详情 -->
      <el-dialog :title="dialog.title" :visible.sync="dialog.isShow" width="99%" top="10px" :close-on-click-modal="false">
        <div style=" width:99%;text-align:right;margin-top:-30px;">
          <el-button type="primary" @click="addCase" style="right:0px;">体系文件</el-button>
        </div>
        <div :style="{'height':(tableHeight+500)+'px','overflow-y':'auto'}">
          <el-tabs v-model="activeName"  @tab-click="detailTabs">
            <el-tab-pane label="客户基本档案信息" name="1">
              <h3 class="dialog-plate-title">
                <span>个人信息</span>
              </h3>
              <!-- 客户基本信息 -->
              <pulpworkInfo v-bind:cardid="dialogBodyCheckList.providerNo"></pulpworkInfo>

              <br />
              <h3 class="dialog-plate-title">
                <span>证件信息</span>
              </h3>
              <el-row :gutter="20" style="margin-right: 0;">
                <el-col :span="2">&nbsp;</el-col>
                <el-col :span="9">
                  <el-upload
                    class="identityCard"
                    :action="idCardPhotoUrl1"
                    :show-file-list="false"
                    :on-success="handleAvatarSuccess"
                    :before-upload="beforeAvatarUpload"
                  >
                    <img
                      v-if="dialogList.providerInfo"
                      :src="'data:image/png;base64,'+ dialogList.providerInfo.idCardPhoto"
                      class="avatar"
                    />
                    <i v-else class="el-icon-plus avatar-uploader-icon">身份证正面</i>
                  </el-upload>
                </el-col>
                <el-col :span="2">&nbsp;</el-col>
                <el-col :span="9">
                  <el-upload
                    class="identityCard"
                    :action="idCardPhotoUrl2"
                    :show-file-list="false"
                    :on-success="handleAvatarSuccess1"
                  >
                    <img
                      v-if="dialogList.providerInfo"
                      :src="'data:image/png;base64,'+ dialogList.providerInfo.idCardPhoto1"
                      class="avatar"
                    />
                    <i v-else class="el-icon-plus avatar-uploader-icon">身份证反面</i>
                  </el-upload>
                </el-col>
                <el-col :span="2">&nbsp;</el-col>
              </el-row>
            </el-tab-pane>
            <el-tab-pane label="体检项" name="2">
              <el-tabs v-model="vitalSignsActiveName" type="card"  @tab-click="vitalSignsTabsHandler">
                  <el-tab-pane label="生命体征" name="1"> 
                      <vsCase v-bind:bodyRecodeId="bodyRecodeId" v-bind:cVal="cVal6" v-bind:providerId="providerId"></vsCase>
                  </el-tab-pane>
                  <el-tab-pane label="脉波压力检测" name="2"> 
                      <stressCase v-bind:bodyRecodeId="bodyRecodeId" v-bind:cVal="cVal7" v-bind:providerId="providerId"></stressCase>
                  </el-tab-pane>
                  <el-tab-pane label="微循环检测" name="3"> 
                      <microcirculation v-bind:bid="bodyRecodeId" v-bind:cVal="cVal8"></microcirculation>
                  </el-tab-pane>
              </el-tabs>
            </el-tab-pane>
            <el-tab-pane label="身体检测" name="11">
              <h3 class="dialog-plate-title" style="margin-top: 15px;"><span>当日检测</span></h3>
              <el-form :inline="true" :model="hTreatmentBodycheck" :rules="dialogRules" ref="dialogRules" label-width="120px" class="demo-ruleForm">
                <el-form-item label="胸部" prop="weight">
                  <el-select v-model="hTreatmentBodycheck.chest">
                    <el-option label="正常" :value="1">正常</el-option>
                    <el-option label="不正常" :value="0">不正常</el-option>
                  </el-select>
                </el-form-item>
                <el-form-item label="腹部" prop="animalHeat">
                  <el-select v-model="hTreatmentBodycheck.abdomen">
                    <el-option label="正常" :value="1">正常</el-option>
                    <el-option label="不正常" :value="0">不正常</el-option>
                  </el-select>
                </el-form-item>
                <el-form-item label="皮肤" prop="pulse">
                  <el-select v-model="hTreatmentBodycheck.skin">
                    <el-option label="正常" :value="1">正常</el-option>
                    <el-option label="不正常" :value="0">不正常</el-option>
                  </el-select>
                </el-form-item>
                 <el-form-item label="四肢" prop="pulse">
                  <el-select v-model="hTreatmentBodycheck.facial">
                    <el-option label="正常" :value="1">正常</el-option>
                    <el-option label="不正常" :value="0">不正常</el-option>
                  </el-select>
                </el-form-item>
                 <el-form-item label="五官" prop="pulse">
                  <el-select v-model="hTreatmentBodycheck.limbs">
                    <el-option label="正常" :value="1">正常</el-option>
                    <el-option label="不正常" :value="0">不正常</el-option>
                  </el-select>
                </el-form-item>

                <el-form-item label="检测医师">
                  <el-select v-model="hTreatmentBodycheck.creatorName">
                    <el-option
                      v-for="item in dictorData"
                      :key="item.name"
                      :value="item.id"
                      :label="item.name"
                    ></el-option>
                  </el-select>
                </el-form-item>
                <el-form-item label="检测时间">
                  <el-input :value="timestampToTime(hTreatmentBodycheck.createTime,'yyyy-mm-dd hh:mm:ss')" ></el-input>             
                </el-form-item>
                <el-button type="primary" @click="submitTodayCase" style="float:right;margin-right:20px;">提交</el-button>
              </el-form>
              <h3 class="dialog-plate-title" style="margin-top: 15px;"><span>历史记录</span></h3>
              <el-table :data="tableHistoryData" stripe border class="company-table" :height="tableHeight" style="width: 95%;">
                <el-table-column prop="chest" label="胸部" sortable min-width="90">
                  <template slot-scope="scope">
                     {{scope.row.chest==0?'不正常':'正常'}}
                  </template>
                </el-table-column>
                <el-table-column prop="abdomen" label="腹部" sortable min-width="110">
                  <template slot-scope="scope">
                     {{scope.row.abdomen==0?'不正常':'正常'}}
                  </template>
                </el-table-column>
                <el-table-column prop="skin" label="皮肤" sortable min-width="110">
                  <template slot-scope="scope">
                     {{scope.row.skin==0?'不正常':'正常'}}
                  </template>
                </el-table-column>
                <el-table-column prop="limbs" label="四肢" sortable min-width="110">
                  <template slot-scope="scope">
                     {{scope.row.limbs==0?'不正常':'正常'}}
                  </template>
                </el-table-column>
                <el-table-column prop="facial" label="五官" sortable min-width="110">
                  <template slot-scope="scope">
                     {{scope.row.facial==0?'不正常':'正常'}}
                  </template>
                </el-table-column>
                <el-table-column prop="creatorName" label="检测医师" sortable min-width="110"></el-table-column>
                <el-table-column prop="createTime" label="检测日期" sortable min-width="110">
                  <template slot-scope="scope">
                     {{timestampToTime(scope.row.createTime,'yyyy-mm-dd hh:mm:ss')}}
                  </template>
                </el-table-column>
              </el-table>   
            </el-tab-pane>
            <el-tab-pane label="外院报告" name="4">
              <el-tabs v-model="outerCourtActiveName" type="card"  @tab-click="outerCourtTabsHandler">
                  <el-tab-pane label="历史" name="5">
                    <historicalCase v-bind:idCard="idCard" v-bind:cVal="cVal5"></historicalCase>
                  </el-tab-pane>
                  <el-tab-pane label="血液" name="1">
                    <bloodCase v-bind:idCard="idCard" v-bind:cVal="cVal1"></bloodCase>
                  </el-tab-pane>
                  <el-tab-pane label="CT检测" name="2">
                    <ctCase v-bind:idCard="idCard" v-bind:cVal="cVal2"></ctCase>
                  </el-tab-pane>
                  <el-tab-pane label="超声" name="3">
                    <ultrasonicCase v-bind:idCard="idCard" v-bind:cVal="cVal3"></ultrasonicCase>
                  </el-tab-pane>
                  <el-tab-pane label="其它" name="4">
                    <otsCase v-bind:idCard="idCard" v-bind:cVal="cVal4"></otsCase>
                  </el-tab-pane>
              </el-tabs>
            </el-tab-pane>
            <el-tab-pane label="接诊病历" name="6">
              <h3 class="dialog-plate-title" style="margin-top: 15px;"><span>病历</span></h3>
              <todayCase :hid="hid" @saveSuccess="saveSuccess" :todayCaseObj="todayCaseObj"></todayCase>              
              <h3 class="dialog-plate-title" style="margin-top: 15px;">
                <span>历史病历</span>
              </h3>
              <el-table :data="tablehTreatmentRecordHistoryData" stripe border class="company-table" :height="tableHeight" style="width: 95%;">
                <el-table-column prop="selfAbout" label="主诉" sortable min-width="90"></el-table-column>
                <el-table-column prop="primaryDiagnosis" label="初步诊断" sortable min-width="110"></el-table-column>
                <el-table-column prop="treatmentOptions" label="治疗意见" sortable min-width="110"></el-table-column>
                <el-table-column prop="creatorName" label="接诊医师" sortable min-width="110"></el-table-column>
                <el-table-column prop="createTime" label="接诊日期" sortable min-width="110">
                  <template slot-scope="scope">
                    <div v-html="timestampToTime(scope.row.createTime,'yyyy-mm-dd hh:mm:ss')"></div>
                  </template>
                </el-table-column>
                <el-table-column fixed="right" label="操作" align="center" min-width="110">
                  <template slot-scope="scope">
                    <el-button  type="text" size="small" @click="showCase(scope.row)">详情</el-button>
                    <el-button  type="text" size="small" @click="showCourseDisease(scope.row)">病程</el-button>
                  </template>
                </el-table-column>
              </el-table>
            </el-tab-pane>
            <el-tab-pane label="院外检测" name="7" style="width:100%;">
              <!-- <span>新增其他医院的【血液检测】、【CT检测】、【超声检查】、【其他】检验报告</span> -->
              <h3 class="dialog-plate-title" style="margin-top: 15px;">
                <span>今日检测</span>
              </h3>   
              <el-button type="primary" @click="insertHOtherCase('1')">新增</el-button> 
              <el-table :data="tableOuterCaseData" stripe border class="company-table">
                  <el-table-column prop="type" label="类型" sortable min-width="200"></el-table-column>
                  <el-table-column prop="creatorName" label="发起医生" sortable min-width="200"></el-table-column>
                  <el-table-column prop="createTime" label="发起日期" sortable min-width="200">
                     <template slot-scope="scope">
                       <div v-html="timestampToTime(scope.row.createTime,'yyyy-mm-dd hh:mm:ss')"></div>
                     </template>
                  </el-table-column>
              </el-table> 
              <h3 class="dialog-plate-title" style="margin-top: 15px;">
                <span>检测历史</span>
              </h3>   
              <el-table :data="tableOuterCaseHistoryData" stripe border class="company-table">
                  <el-table-column prop="type" label="类型" sortable min-width="200"></el-table-column>
                  <el-table-column prop="creatorName" label="发起医生" sortable min-width="200"></el-table-column>
                  <el-table-column prop="createTime" label="发起日期" sortable min-width="200">
                     <template slot-scope="scope">
                       <div v-html="timestampToTime(scope.row.createTime,'yyyy-mm-dd hh:mm:ss')"></div>
                     </template>
                  </el-table-column>
              </el-table>  
            </el-tab-pane>
            <el-tab-pane label="院内血液检测" name="3">
              <innerbloodCase v-bind:idCard="idCard" v-bind:cVal="cValinner" v-bind:hid="hid"></innerbloodCase>
            </el-tab-pane>
            <el-tab-pane label="知情同意书" name="10">
              <informedConsent  v-bind:cVal="cValZqtys" v-bind:hid="hid" v-bind:providerId="providerId"></informedConsent>
            </el-tab-pane>
            <el-tab-pane label="治疗方案拟定" name="5">
              <div style="border:1px solid black;width:98%;height:1px;margin-bottom:10px;">
                <el-form
                  :inline="true"
                  :model="dialogList"
                  label-width="120px"
                  class="demo-ruleForm"
                >
                </el-form>
              </div>
                <h3 class="dialog-plate-title" style="margin-top: 15px;">
                   <span>待选方案</span>
                </h3>
              <el-collapse v-model="createPlanActiveNames" @change="createPlanHandleChange">
                <el-collapse-item name="planTableArea">
                  <el-table :data="planTableData" stripe border style="width: 100%" class="company-table">
                      <el-table-column prop="weight" label="体重" sortable min-width="50"></el-table-column>
                      <el-table-column prop="allTotal" label="全血总量" sortable min-width="50"></el-table-column>
                      <el-table-column prop="epv" label="EPV" sortable min-width="50"></el-table-column>
                      <el-table-column prop="hct" label="HCT" sortable min-width="50"></el-table-column>
                      <el-table-column prop="leaveBl" label="允许离体全血占比" sortable min-width="50"></el-table-column>
                      <el-table-column prop="targetHct" label="目标HCT" sortable min-width="50"></el-table-column>
                      <el-table-column prop="leaveBlTotal" label="允许离体全血总量" sortable min-width="50"></el-table-column>
                      <el-table-column prop="targetLeaveBlTotal" label="目标血浆去除总量" sortable min-width="50"></el-table-column>
                      <el-table-column prop="sumLeaveBlTotal" label="累计工艺性血浆去除量" sortable min-width="50"></el-table-column>
                      <el-table-column prop="singleLayerMax" label="单层最大出浆量" sortable min-width="50"></el-table-column>
                      <el-table-column prop="hxbLeaveTotal" label="红细胞去除总量" sortable min-width="50"></el-table-column>
                      <el-table-column prop="predictHxbLeaveCount" label="预估红细胞去除次数" sortable min-width="50"></el-table-column>
                      <el-table-column prop="shineAllBlood" label="照射全血总量" sortable min-width="50"></el-table-column>
                      <el-table-column fixed="right" label="操作" align="left" min-width="75">
                          <template slot-scope="scope">
                              <span v-if="scope.row.hid!=null">
                                  已下发
                              </span>
                              <span v-else>
                              <el-button  @click="submitUpdatePlan(scope.row)" type="text" size="small">下发方案</el-button>
                              </span>
                          </template>         
                      </el-table-column>
                  </el-table>
                </el-collapse-item>
                  <h3 class="dialog-plate-title" style="margin-top: 15px;">
                     <span>接诊趋势</span>
                    </h3>
                  <el-collapse-item name="5">
                    <div :style="{width:autoWidth+'px',height:(autoHeight*3+30)+'px'}">
                      <div id="lineTotlal" class="marginCenter" :style="{width:autoWidth-200+'px',height:autoHeight+'px'}"></div>
                      <div id="lineXj" class="marginCenter" :style="{width:autoWidth-200+'px',height:autoHeight+'px'}"></div>
                      <div id="lineHxb" class="marginCenter" :style="{width:autoWidth-200+'px',height:autoHeight+'px'}"></div>
                    </div>
                  </el-collapse-item>
                <br />
                <div id="createPlan" style="padding:10px;">
                  <h3 class="dialog-plate-title" style="margin-top: 15px;">
                    <span>方案拟定</span>
                  </h3>
                   <pePlan v-bind:data="baseInfo" v-bind:cVal="cValPlan" v-bind:providerNo="providerId" v-bind:hid="hid" @sendDataToParent="getDataFromChild"></pePlan>
                </div>
              </el-collapse>
              <el-button type="primary" style="float:right;" @click="addPlanByDoctor">下发方案</el-button>
            </el-tab-pane>
            <el-tab-pane label="治疗计划" name="12">
              <treatmentPlan :providerId="providerId"></treatmentPlan>
            </el-tab-pane>
          </el-tabs>
        </div>
        <div slot="footer">
        </div>
      </el-dialog>
      <!-- 实验室新增 -->
      <el-dialog :title="dialog4.title" :visible.sync="dialog4.isShow" width="70%" top="70px" :close-on-clcick-modal="false" class="dialog-form">
        <div :style="{'height':(tableHeight-90)+'px','overflow-y':'auto'}">
          <el-form :inline="true" ref="bodyCheckForm" :model="dialogBodyCheckList" label-width="100px" class="demo-ruleForm" :rules="bodycheckRules">
            <el-form-item label="检验项目名称" prop="proName">
              <el-input v-model="dialogBodyCheckList.proName"></el-input>
            </el-form-item>
            <el-form-item label="检验次数" prop="sampleNums">
              <el-input v-model="dialogBodyCheckList.sampleNums"></el-input>
            </el-form-item>
            <el-form-item label="客户" prop="providerNo">
              <el-input v-model="dialogBodyCheckList.providerNo"></el-input>
            </el-form-item>
          </el-form>
        </div>
        <div slot="footer" style="text-align: right;">
          <el-button type="primary" @click="submitBodyCheckDialog">提交</el-button>
        </div>
      </el-dialog>
      <el-dialog :visible.sync="dialogForOutsideCheck.isShow" width="25%" top="70px" :close-on-clcick-modal="false" class="dialog-form">
        <el-form :inline="true" :model="outsideCheck" label-width="100px" class="demo-ruleForm">
          <el-form-item label="检测类型"> 
            <el-select v-model="outsideCheck.type">
              <el-option key="血液检测" value="血液检测" label="血液检测" ></el-option>  
              <el-option key="CT检测" value="CT检测" label="CT检测"></el-option>
              <el-option key="超声检查" value="超声检查" label="超声检查"></el-option>
              <el-option key="其他" value="其他" label="其他"></el-option>
            </el-select>
          </el-form-item> 
          <el-table-column>
            <el-button type="primary" @click="submitOutsideCheck">提交</el-button>
          </el-table-column>
        </el-form>
      </el-dialog>
      <el-dialog :title="courseDiseaseDialog.title" :visible.sync="courseDiseaseDialog.open" width="90%" top="70px" :close-on-clcick-modal="false" class="dialog-form">
        <courseDisease :hid="courseDiseaseDialog.pid" ref="courseDisease"></courseDisease>
      </el-dialog>
      <el-dialog :title="caseDialog.title" :visible.sync="caseDialog.open" width="90%" top="70px" :close-on-clcick-modal="false" class="dialog-form">
       <todayCase  :todayCaseObj="caseDialog.formdata" :disabled='true'></todayCase> 
      </el-dialog>
    </div>
  </div>
</template>
<script>
import echarts from "echarts";
import api from "plugins/axios/api.js";
import {getCacheTodayCase} from "plugins/axios/inquiryRecord.js";
import regx from "plugins/regx.js";
import pulpworkInfo from "views/operationManage/components/pulpworkInfo.vue";
import pePlan from 'views/operationManage/components/interrogation/pePlan.vue';
import informedConsent from 'views/operationManage/components/interrogation/InformedConsent.vue';
import historicalCase from 'views/operationManage/components/bodyCheck/historicalCase.vue';
import bloodCase from 'views/operationManage/components/bodyCheck/bloodCase.vue';
import innerbloodCase from 'views/operationManage/components/bodyCheck/innerBloodCase.vue';
import ctCase from 'views/operationManage/components/bodyCheck/ctCase.vue';
import ultrasonicCase from 'views/operationManage/components/bodyCheck/ultrasonicCase.vue';
import otsCase from 'views/operationManage/components/bodyCheck/otsCase.vue';
import vsCase from 'views/operationManage/components/bodyCheck/vitalSignsCase.vue';
import stressCase from 'views/operationManage/components/bodyCheck/stressCase.vue';
import microcirculation from 'views/operationManage/components/bodyCheck/microcirculation.vue';
// 今日病历
import todayCase from 'views/operationManage/components/inquiryRecord/todayCase.vue';
// 病程
import courseDisease from 'views/operationManage/components/inquiryRecord/courseDisease.vue';

import treatmentPlan from 'views/operationManage/components/inquiryRecordDetail/treatmentPlan.vue';
export default {
  components: {
    pulpworkInfo,
    pePlan,
    historicalCase,
    bloodCase,
    innerbloodCase,
    ctCase,
    ultrasonicCase,
    otsCase,
    vsCase,
    stressCase,
    microcirculation,
    informedConsent,
    todayCase,
    courseDisease,
    treatmentPlan
  },
  computed: {
    tableHeight() {
      return this.$store.state.clientHeight - 184;
    },
    divAutoHeight() {
      return this.$store.state.clientHeight;
    },
    divAutoWidth() {
      return this.$store.state.clientWidth - 100;
    },
    autoHeight() {
      return this.$store.state.clientHeight / 2 - 55;
    },
    autoWidth() {
      return this.$store.state.clientWidth - 55;
    }
  },
  data() {
    return {
      baseInfo:{
        sex:null,
        weight:null,
      },
      tableOuterCaseData:[],
      tableOuterCaseHistoryData:[],
      tableHistoryData:[],
      tablehTreatmentRecordHistoryData:[],
      planTableData:[],
      createTopTitle: [
        "性别",
        "体重(kg)",
        "全血总量(ml)",
        "HCT",
        "允许离体全血占比",
        "目标HCT",
        "目标去除EPV比例",
        "目标照射全血占比",
        "目标血浆照射占比"
      ],
      hTreatmentBodycheck:{
        id:'',       //id
        hid:'',      // 问诊id
        chest:'1',    // 胸
        abdomen:'1',  // 腹部
        skin:'1',     // 皮肤
        facial:'1',    // 五官
        limbs:'1',     // 四肢
        creator:'1',   // 创建人
        creatorName:'1', // 创建人名称
        createTime:new Date(), // 创建时间
        remark:'',    // 备注
      },
      todayCaseObj:{},
      blrecord:{
         id:'', //id
         hid:'', //hid
         attackTime:new Date(), //发病日期
         selfAbout:'1', //主述
         nowDisease:'1', //现病史
         pastDisease:'1', //既往史
         allergy:'1', //过敏史
         allergyName:'1', //过敏史名称
         mfHistory:'1', //月经生育史
         traumaHistory:'1', //外伤史
         poisoning:'1', //中毒史
         poisoningName:'1', //中毒史名称
         primaryDiagnosis:'1', //初步诊断
         treatmentOptions:'1', //治疗意见
         creator:'1', //创建人
         creatorName:'1', //创建人姓名
         createTime:new Date(), //创建时间
      },
      outsideCheck:{
         id:'', //id
         hid:'', //hid
         name:'', //hid
         type:'', //hid
         creator:'', //hid
         creatorName:'', //hid
         createTime:'', //hid
      },
      hid:'',
      providerId:'', 
      idCard:null,
      cVal1:null,
      cVal2:null,
      cVal3:null,
      cVal4:null,
      cVal5:null,
      cVal6:null,
      cVal7:null,
      cVal8:null,
      cValinner:null,
      cValZqtys:null,
      cValPlan:null,
      bodyRecodeId:null,
      registerNo:null,
      createPlanActiveNames: ["0", "2","planTableArea"],
      mainActiveName: "0",
      outerCourtActiveName:'5',
      vitalSignsActiveName:'1',

      tableOneData: [
        {
          weight: 125,
          animalHeat: 123,
          time: "3小时",
          bodyCheckWorkerDesc: "张三",
          createNurse: "李四"
        }
      ],
      search: {
        cardid: "",
        name: "",
        time: [],
        currentStatus:0,
        recodeStatus: 0
      },
      t_oneData: [
        { indexName: "1层", hxbl: 4399, xjl: 3499, xjbl: "60%" },
        { indexName: "2层", hxbl: 4399, xjl: 3499, xjbl: "60%" }
      ],
      planData: {
        sex: "男", //性别
        weight: 45, //体重
        allTotal: 3900, //全血总量
        epv: 2000, //EPV
        hct: 0.5, //HCT
        leaveBl: 0.17, //允许离体全血占比
        leaveBlTotal: 3800, //允许离体全血总量
        targetHct: 0.4, //目标HCT
        targetLeaveEpv: 0.25, //目标去除EPV比例
        targetAllBl: 0.1, //目标照射全血占比
        targetXjBl: 0.6, //目标血浆照射占比
        targetLeaveBlTotal: 4399, //目标血浆去除总量
        sumLeaveBlTotal: 4399, //累计工艺性血浆去除量
        epvLeaveBl: 0.35, //EPV去除比例
        singleLayerMax: 165, //单层最大出浆量
        singleLayerMin: 10, //最小单层去除血浆量
        hxbLeaveTotal: 390, //红细胞去除总量
        predictHxbLeaveCount: 2, //预估红细胞去除次数
        singleMaxLeave: 245, //单层最大去除量
        aRatioAllBlood: "1:16.0", //抗凝剂/全血比例
        cuffPressure: 50, //袖带压力
        acquisitionSpeed: 60, //采集速度
        voReturn: 60, //还输速度
        shineAllBlood: 780, //照射全血总量
        singShineMax: 260, //单次照射最大量
        singleShineAllBlood: 260, //单层照射全血量
        predictShineCount: 2, //预估照射次数
        loopCount: 2, //循环次数
        loopCountDataR: [
          //循环：层数/红细胞/血浆/占比 数据
          { indexName: "1层", hxbl: 4399, xjl: 3499, xjbl: "60%" },
          { indexName: "2层", hxbl: 4399, xjl: 3499, xjbl: "60%" }
        ],
        loopCountDataT: [
          //循环：层数/照射时间/充氧时间
          { indexName: "1层", hxbl: 4399, xjl: 3499, xjbl: "60%" },
          { indexName: "2层", hxbl: 4399, xjl: 3499, xjbl: "60%" }
        ],
        preMiningBrineSupplement: 200, //采前盐水补充量
        channelMaintenance: 5, //通道维持量
        packingPressure: 50, //保压压力
        predictMiningBrineSupplement: 888 //预估盐水补充量
      },
      tableData: [],
      dictorData: {},
      pagination: {
        currentPage: 1,
        pageSize: 10,
        total: 0
      },
      idCardPhotoUrl1: null,
      idCardPhotoUrl2: null,
      dialog4: {
        title: "",
        isShow: false
      },
      dialogList: {
        createNurseName: localStorage.getItem("ms_username"),
        dialogSeeAllZqtysmb: ""

      },
      dialogForOutsideCheck:{
        isShow:false,
      },
      appendixUrl: "/api/adscm/filesystem/abc",
      bodyCheckData: [],
      bodycheckRules: {
        proName: [
          { required: true, message: "请选择是否合格", trigger: "blur" }
        ],
        sampleNums: [
          { required: true, message: "请输入检查单位", trigger: "blur" }
        ],
        providerNo: [
          { required: true, message: "请输入检查医生", trigger: "blur" }
        ]
      },
      dialogBodyCheckList: {}, //接诊
      dialogRules: {
        weight: [
          { required: true, message: "请输入体重...", trigger: "blur" },
          {
            type: "number",
            message: "体重不能高于150Kg，低于45Kg",
            trigger: "blur",
            validator: regx.validateWeight
          }
        ],
        animalHeat: [
          { required: true, message: "请输入体温...", trigger: "blur" },
          {
            type: "number",
            message: "体温不能高于37.2 ℃，低于36.3 ℃",
            trigger: "blur",
            validator: regx.validateAnimalHeat
          }
        ],
        pulse: [
          { required: true, message: "请输入脉搏...", trigger: "blur" },
          {
            type: "number",
            message: "脉搏不能高于100/B/M，低于60/B/M",
            trigger: "blur",
            validator: regx.validatePulse
          }
        ],
        lowBlood: [
          { required: true, message: "请输入低血压...", trigger: "blur" },
          {
            type: "number",
            message: "低压不能高于8/KPa，低于12/KPa",
            trigger: "blur",
            validator: regx.validateLowBlood
          }
        ],
        highBlood: [
          { required: true, message: "d请输入高血压...", trigger: "blur" },
          {
            type: "number",
            message: "高压不能高于12/KPa，低于20/KPa",
            trigger: "blur",
            validator: regx.validateHighBlood
          }
        ]
      },
      dialog: {
        title: "",
        isShow: false
      },
      activeName: "",
      caseData: [],
      courseDiseaseDialog:{
        pid:'',
        open:false,
        title:''
      },
      caseDialog:{
        formdata:{},
        open:false,
        title:''
      }
    };
  },
  created() {
    this.getData();
  },
  mounted() {},

  methods: {
    createInnerBloodCase(){
      let self = this;
      
    },
    insertHOtherCase(type){
      let self = this;
      self.dialogForOutsideCheck.isShow = true;
      switch (type) {
        case '1':  break;
        case '2': break;
        default:
          break;
      }
    },
    submitTodayCase(){
      let self = this;
      self.hTreatmentBodycheck.hid = self.hid;
      api.insertTodayCase(self.hTreatmentBodycheck).then(res=>{
          self.$message("提交成功!");
          self.queryhTreatmentBodycheckByHid();
          self.queryhTreatmentBodycheckHistoryByHid();
      });
    },
    saveSuccess(){
      this.queryhTreatmentRecordBodycheckByHid();
      this.queryhTreatmentRecordBodycheckHistoryByHid();
    },
    submitOutsideCheck(){
      let self = this;
      self.outsideCheck.hid = self.hid;
      self.outsideCheck.creatorName = null;
      self.outsideCheck.createTime = null;
      api.insertOutsideCheck(self.outsideCheck).then(res=>{
          self.$message("提交成功!");
          self.queryOutsideCheckByHid();
          self.queryOutsideCheckHistoryByHid();
          self.dialogForOutsideCheck.isShow = false;
      });
    },
    vitalSignsTabsHandler(ins){
      let self = this;
      switch (ins.name) {
        case '1':
          self.cVal6 = Math.random(10000);
          break; 
        case '2':
          self.cVal7 = Math.random(10000);
          break; 
        case '8':
          self.cVal8 = Math.random(10000);
          break;
        default:
          break;
      }

    },
    outerCourtTabsHandler(ins){
      let self = this;
      switch (ins.name) {
        case '1':
        self.cVal1 = Math.random(10000);
          break;
        case '2':
        self.cVal2 = Math.random(10000);
          break;
        case '3':
        self.cVal3 = Math.random(10000);
          break;
        case '4':
        self.cVal4 = Math.random(10000);
          break;
        case '5':
        self.cVal5 = Math.random(10000);
          break;     
        default:
          break;
      }
    },
    submitUpdatePlan(row){
      let self = this;
      row.hid = self.hid;
      api.insertPePlanConfirm(row).then(res=>{
         if(res){
           self.$message.error("下发成功");
         }
      });
    },
    //拼接返回值
    appenDataForSeeAllZqtysmb(data) {
      
     let name__ = this.dialogList.providerInfo.name;
     let idCard__ = this.dialogList.providerInfo.idNo;

     let pf = data.prefix.replace(/{providerName}/, name__);
     pf = pf.replace(/{providerCardNum}/, idCard__);
  

     let result__ = "<div>" +
        pf +
        "</div>" +
        "<div>" +
        data.templateContent +
        "</div>" +
        "<div>" +
        data.suffix +
        "</div>";
      return result__;
        
      
    },
    changeEventhandler(val, type) {
      let self = this;
      switch (type) {
        case "weight":
          self.computeAllTotal();
          break; //修改页面【体重】,重新计算【全血总量】
        case "hct":
          self.computeSingleLayerMax();
          break; //修改页面【HCT】值，重新计算【单层最大出浆量】
        case "leaveBl":
          self.computeLeaveBlTotal();
          break; //修改页面【允许离体全血占比】，重新计算【允许离体全血量】
        case "targetLeaveEpv":
          self.computeTargetLeaveBlTotal();
          break; //修改页面【目标去除EPV比例】,  重新计算【目标血浆去除总量】
        case "targetAllBl":
          self.computeShineAllBlood();
          break; //修改页面【目标照射全血占比】,  重新计算【照射全血总量】
        case "targetXjBl":
          self.computeLoopCountDataR();
          break; //修改页面【目标血浆照射占比】,  重新计算【每层照射数据】
        case "singShineMax":
          self.computePredictShineCount();
          break; //修改页面【单次照射最大量】,  重新计算【预估照射次数】
        default:
          break;
      }
    },
    //计算全血总量
    computeAllTotal() {
      let self = this;
      self.planData.allTotal = self.planData.weight * 0.065 * 1000;
      self.computeEpv(); //同步更新【Epv】值
      self.computeLeaveBlTotal(); //同步更新【允许离体全血】值
      self.computeShineAllBlood(); //同步更新【照射全血总量】值
    },
    //单层最大出浆量
    computeSingleLayerMax() {
      let self = this;
      self.planData.singleLayerMax = 275 * (0.8 / self.planData.hct - 1);
    },
    //计算EPV
    computeEpv() {
      let self = this;
      if (self.planData.sex === "男") {
        self.planData.epv =
          (1 - self.planData.hct) * (1530 + 41 * self.planData.weight);
      } else if (self.planData.sex === "女") {
        self.planData.epv =
          (1 - self.planData.hct) * (864 + 47.2 * self.planData.weight);
      }
      self.computeTargetLeaveBlTotal();
    },
    //进行【允许离体全血】计算
    computeLeaveBlTotal() {
      let self = this;
      self.planData.leaveBlTotal =
        self.planData.leaveBl * self.planData.allTotal;
      //待关联计算实际离体全血量
    },
    //进行【目标血浆去除总量】计算
    computeTargetLeaveBlTotal() {
      let self = this;
      self.planData.targetLeaveBlTotal =
        self.planData.targetLeaveEpv * self.planData.epv;
    },
    //进行【照射全血总量】计算
    computeShineAllBlood() {
      let self = this;
      self.planData.shineAllBlood =
        self.planData.targetAllBl * self.planData.allTotal;
      self.computePredictShineCount();
    },
    //进行【每层照射数据】计算
    computeLoopCountDataR() {
      let self = this;
      let xjCount =
        self.planData.singleShineAllBlood * self.planData.targetXjBl;
      let hxbCount = self.planData.singleShineAllBlood - xjCount;
      self.planData.loopCountDataR;
    },
    //计算预估照射次数
    computePredictShineCount() {
      let self = this;
      self.planData.predictShineCount = Math.ceil(
        self.planData.shineAllBlood / self.planData.singShineMax
      );
      self.planData.loopCount = self.planData.predictShineCount;
      self.computeSingleShineAllBlood();
    },
    //计算单层照射全血量
    computeSingleShineAllBlood() {
      let self = this;
      self.planData.singleShineAllBlood =
        self.planData.shineAllBlood / self.planData.predictShineCount;
      self.computeLoopCountDataR();
    },
    //计算
    createPlanHandleChange(val) {
      let self = this;
      console.log(val);
    },
    syschRecodeStatus(ins) {
      let self = this;
      self.dialogList.createNurseName = localStorage.getItem("ms_username");
      switch (ins.name) {
        case "2":
          self.search.currentStatus = 2;
          self.getData();
          break;
        case "1":
          self.search.currentStatus = 1;
          self.getData();
          break;
        case "0":
          self.search.currentStatus = 0;
          self.getData();
          break;
        default:
          break;
      }
    },
    detailTabs(ins) {
      let self = this;
      switch (ins.name) {
        case "10":
          self.cValZqtys = Math.random(10000);
          break;
        case "1":
        
          break;
        case "0":
        
          break;
        case "5":
          self.cValPlan = Math.random(10000);
          break; 
        case "6":
           self.queryhTreatmentRecordBodycheckByHid();
           self.queryhTreatmentRecordBodycheckHistoryByHid();
          break; 
        case "7":
           self.queryOutsideCheckByHid();
           self.queryOutsideCheckHistoryByHid();
          break;
        case "11":
           self.queryhTreatmentBodycheckByHid();
           self.queryhTreatmentBodycheckHistoryByHid();
          break; 
        case "3":
           self.cValinner = Math.random(10000);
          break;
        default:
          break;
      }
    },
    //初始化折线统计图
    initLine() {
      let self = this;
      //self.queryInitLineData();
      self.queryInitLineTotalData();
      self.queryInitLineXjData();
      self.queryInitLineHxbData();
    },
    //查询折线统计图数据
    queryInitLineData() {
      let self = this;

      self.createInitLine();

    }, //查询折线统计图数据
    queryInitLineTotalData() {
      let self = this;

      self.createInitLineTotal();

    }, //查询折线统计图数据
    queryInitLineXjData() {
      let self = this;

      self.createInitLineXj();

    },
    //查询折线统计图数据
    queryInitLineHxbData() {
      let self = this;
      self.createInitLineHxb();
    },
    //创建折线统计图
    createInitLine() {
      let self = this;

      let div = document.getElementById("line");
      let echartsLine = echarts.init(div);
      self.setInitLineOption(echartsLine);
    }, //创建折线统计图
    createInitLineTotal() {
      let self = this;
      let div = document.getElementById("lineTotlal");
      let echartsLine = echarts.init(div);
      self.setInitLineTotalOption(echartsLine);
    }, //创建折线统计图
    createInitLineXj() {
      let self = this;

      let div = document.getElementById("lineXj");
      let echartsLine = echarts.init(div);
      self.setInitLineXjOption(echartsLine);
    }, //创建折线统计图
    createInitLineHxb() {
      let self = this;

      let div = document.getElementById("lineHxb");
      let echartsLine = echarts.init(div);
      self.setInitLineHxbOption(echartsLine);
    },
    setInitLineTotalOption(echartsDiv) {
      let option;
      option = {
        title: {
          text: "综合折线图",
          left: "left"
        },
        legend: {
          data: ["HCT", "EPV", "照射剂量", "能量"]
        },
        tooltip: {
          backgroundColor: "#F6F6F6",
          borderWidth: 1,
          borderColor: "rgba(0,0,0,.3)",
          triggerOn: "click",
          confine: true,
          enterable: true,
          transitionDuration: 0,
          textStyle: {
            color: "#333"
          },
          extraCssText: "box-shadow: 0 0 5px 1px rgba(255, 255, 255, 0.3);",
          padding: [5, 10],
          position: function(pos, params, dom, rect, size) {
            return [pos[0] + 10, pos[1]];
          },
          formatter: function(params) {
            if (params != undefined && params != null) {
              if (params.value[1] == 100) return "1.0";
              else return params.value[1] / 100;
            } else {
              return "数据错误!";
            }
          }
        },
        grid: {
          left: "2%",
          right: "2%",
          bottom: "5%",
          containLabel: true
        },
        xAxis: [
          {
            type: "category",
            boundaryGap: false,
            axisTick: {
              alignWithLabel: true
            },
            data: ["0", "1", "2", "3", "4", "5"]
          }
        ],
        yAxis: {
          type: "value",
          min: 0,
          max: 100,
          splitNumber: 10,
          axisLabel: {
            show: true,
            interval: 10,
            formatter: function(value) {
              if (value == 100 || value > 100) {
                return "1.0";
              } else {
                return value / 100;
              }
            }
          },
          show: true
        },
        dataZoom: [
          {
            type: "inside",
            start: 0,
            end: 100
          },
          {
            start: 10,
            end: 10,
            handleIcon:
              "M10.7,11.9v-1.3H9.3v1.3c-4.9,0.3-8.8,4.4-8.8,9.4c0,5,3.9,9.1,8.8,9.4v1.3h1.3v-1.3c4.9-0.3,8.8-4.4,8.8-9.4C19.5,16.3,15.6,12.2,10.7,11.9z M13.3,24.4H6.7V23h6.6V24.4z M13.3,19.6H6.7v-1.4h6.6V19.6z",
            handleSize: "80%",
            handleStyle: {
              color: "#fff",
              shadowBlur: 3,
              shadowColor: "rgba(0, 0, 0, 0.6)",
              shadowOffsetX: 2,
              shadowOffsetY: 2
            }
          }
        ],
        series: [
          {
            name: "HCT",
            type: "line",
            data: [
              { name: "HCT", value: ["0", 50, 100, 200] },
              { name: "HCT", value: ["1", 50, 100, 200] },
              { name: "HCT", value: ["2", 50, 100, 200] },
              { name: "HCT", value: ["3", 100, 100, 200] },
              { name: "HCT", value: ["4", 100, 100, 200] },
              { name: "HCT", value: ["5", 100, 100, 200] }
            ]
          },
          {
            name: "EPV",
            type: "line",
            data: [
              { name: "EPV", value: ["0", 10, 100, 200] },
              { name: "EPV", value: ["1", 22, 100, 200] },
              { name: "EPV", value: ["2", 33, 100, 200] },
              { name: "EPV", value: ["3", 44, 100, 200] },
              { name: "EPV", value: ["4", 55, 100, 200] },
              { name: "EPV", value: ["5", 66, 100, 200] }
            ]
          },
          {
            name: "照射剂量",
            type: "line",
            data: [
              { name: "照射剂量", value: ["0", 44, 100, 200] },
              { name: "照射剂量", value: ["1", 50, 100, 200] },
              { name: "照射剂量", value: ["2", 65, 100, 200] },
              { name: "照射剂量", value: ["3", 33, 100, 200] },
              { name: "照射剂量", value: ["4", 17, 100, 200] },
              { name: "照射剂量", value: ["5", 99, 100, 200] }
            ]
          },
          {
            name: "能量",
            type: "line",
            data: [
              { name: "能量", value: ["0", 12, 100, 200] },
              { name: "能量", value: ["1", 32, 100, 200] },
              { name: "能量", value: ["2", 54, 100, 200] },
              { name: "能量", value: ["3", 78, 100, 200] },
              { name: "能量", value: ["4", 12, 100, 200] },
              { name: "能量", value: ["5", 90, 100, 200] }
            ]
          }
        ]
      };
      echartsDiv.setOption(option);
    },
    setInitLineXjOption(echartsDiv) {
      let option;
      option = {
        title: {
          text: "血浆折线图",
          textAlign: "auto"
        },
        legend: {
          data: ["SOD", "LP", "MDA"]
        },
        tooltip: {
          backgroundColor: "#F6F6F6",
          borderWidth: 1,
          borderColor: "rgba(0,0,0,.3)",
          triggerOn: "click",
          confine: true,
          enterable: true,
          transitionDuration: 0,
          textStyle: {
            color: "#333"
          },
          extraCssText: "box-shadow: 0 0 5px 1px rgba(255, 255, 255, 0.3);",
          padding: [5, 10],
          position: function(pos, params, dom, rect, size) {
            return [pos[0] + 10, pos[1]];
          },
          formatter: function(params) {
            if (params != undefined && params != null) {
              if (params.value[1] == 100) return "1.0";
              else return params.value[1] / 100;
            } else {
              return "数据错误!";
            }
          }
        },
        grid: {
          left: "2%",
          right: "2%",
          bottom: "5%",
          containLabel: true
        },
        xAxis: [
          {
            type: "category",
            boundaryGap: false,
            axisTick: {
              alignWithLabel: true
            },
            data: ["0", "1", "2", "3", "4", "5"]
          }
        ],
        yAxis: {
          type: "value",
          min: 0,
          max: 100,
          splitNumber: 10,
          axisLabel: {
            show: true,
            interval: 10,
            formatter: function(value) {
              if (value == 100 || value > 100) {
                return "1.0";
              } else {
                return value / 100;
              }
            }
          },
          show: true
        },
        dataZoom: [
          {
            type: "inside",
            start: 0,
            end: 100
          },
          {
            start: 10,
            end: 10,
            handleIcon:
              "M10.7,11.9v-1.3H9.3v1.3c-4.9,0.3-8.8,4.4-8.8,9.4c0,5,3.9,9.1,8.8,9.4v1.3h1.3v-1.3c4.9-0.3,8.8-4.4,8.8-9.4C19.5,16.3,15.6,12.2,10.7,11.9z M13.3,24.4H6.7V23h6.6V24.4z M13.3,19.6H6.7v-1.4h6.6V19.6z",
            handleSize: "80%",
            handleStyle: {
              color: "#fff",
              shadowBlur: 3,
              shadowColor: "rgba(0, 0, 0, 0.6)",
              shadowOffsetX: 2,
              shadowOffsetY: 2
            }
          }
        ],
        series: [
          {
            name: "SOD",
            type: "line",
            data: [
              { name: "HCT", value: ["0", 50, 100, 200] },
              { name: "HCT", value: ["1", 50, 100, 200] },
              { name: "HCT", value: ["2", 50, 100, 200] },
              { name: "HCT", value: ["3", 100, 100, 200] },
              { name: "HCT", value: ["4", 100, 100, 200] },
              { name: "HCT", value: ["5", 100, 100, 200] }
            ]
          },
          {
            name: "LP",
            type: "line",
            data: [
              { name: "EPV", value: ["0", 10, 100, 200] },
              { name: "EPV", value: ["1", 22, 100, 200] },
              { name: "EPV", value: ["2", 33, 100, 200] },
              { name: "EPV", value: ["3", 44, 100, 200] },
              { name: "EPV", value: ["4", 55, 100, 200] },
              { name: "EPV", value: ["5", 66, 100, 200] }
            ]
          },
          {
            name: "MDA",
            type: "line",
            data: [
              { name: "照射剂量", value: ["0", 44, 100, 200] },
              { name: "照射剂量", value: ["1", 50, 100, 200] },
              { name: "照射剂量", value: ["2", 65, 100, 200] },
              { name: "照射剂量", value: ["3", 33, 100, 200] },
              { name: "照射剂量", value: ["4", 17, 100, 200] },
              { name: "照射剂量", value: ["5", 99, 100, 200] }
            ]
          }
        ]
      };
      echartsDiv.setOption(option);
    },
    setInitLineHxbOption(echartsDiv) {
      let option;
      option = {
        title: {
          text: "红细胞折线图",
          textAlign: "auto"
        },
        legend: {
          data: ["SOD", "LP", "MDA"]
        },
        tooltip: {
          backgroundColor: "#F6F6F6",
          borderWidth: 1,
          borderColor: "rgba(0,0,0,.3)",
          triggerOn: "click",
          confine: true,
          enterable: true,
          transitionDuration: 0,
          textStyle: {
            color: "#333"
          },
          extraCssText: "box-shadow: 0 0 5px 1px rgba(255, 255, 255, 0.3);",
          padding: [5, 10],
          position: function(pos, params, dom, rect, size) {
            return [pos[0] + 10, pos[1]];
          },
          formatter: function(params) {
            if (params != undefined && params != null) {
              if (params.value[1] == 100) return "1.0";
              else return params.value[1] / 100;
            } else {
              return "数据错误!";
            }
          }
        },
        grid: {
          left: "2%",
          right: "2%",
          bottom: "5%",
          containLabel: true
        },
        xAxis: [
          {
            type: "category",
            boundaryGap: false,
            axisTick: {
              alignWithLabel: true
            },
            data: ["0", "1", "2", "3", "4", "5"]
          }
        ],
        yAxis: {
          type: "value",
          min: 0,
          max: 100,
          splitNumber: 10,
          axisLabel: {
            show: true,
            interval: 10,
            formatter: function(value) {
              if (value == 100 || value > 100) {
                return "1.0";
              } else {
                return value / 100;
              }
            }
          },
          show: true
        },
        dataZoom: [
          {
            type: "inside",
            start: 0,
            end: 100
          },
          {
            start: 10,
            end: 10,
            handleIcon:
              "M10.7,11.9v-1.3H9.3v1.3c-4.9,0.3-8.8,4.4-8.8,9.4c0,5,3.9,9.1,8.8,9.4v1.3h1.3v-1.3c4.9-0.3,8.8-4.4,8.8-9.4C19.5,16.3,15.6,12.2,10.7,11.9z M13.3,24.4H6.7V23h6.6V24.4z M13.3,19.6H6.7v-1.4h6.6V19.6z",
            handleSize: "80%",
            handleStyle: {
              color: "#fff",
              shadowBlur: 3,
              shadowColor: "rgba(0, 0, 0, 0.6)",
              shadowOffsetX: 2,
              shadowOffsetY: 2
            }
          }
        ],
        series: [
          {
            name: "SOD",
            type: "line",
            data: [
              { name: "HCT", value: ["0", 50, 100, 200] },
              { name: "HCT", value: ["1", 50, 100, 200] },
              { name: "HCT", value: ["2", 50, 100, 200] },
              { name: "HCT", value: ["3", 100, 100, 200] },
              { name: "HCT", value: ["4", 100, 100, 200] },
              { name: "HCT", value: ["5", 100, 100, 200] }
            ]
          },
          {
            name: "LP",
            type: "line",
            data: [
              { name: "EPV", value: ["0", 10, 100, 200] },
              { name: "EPV", value: ["1", 22, 100, 200] },
              { name: "EPV", value: ["2", 33, 100, 200] },
              { name: "EPV", value: ["3", 44, 100, 200] },
              { name: "EPV", value: ["4", 55, 100, 200] },
              { name: "EPV", value: ["5", 66, 100, 200] }
            ]
          },
          {
            name: "MDA",
            type: "line",
            data: [
              { name: "照射剂量", value: ["0", 44, 100, 200] },
              { name: "照射剂量", value: ["1", 50, 100, 200] },
              { name: "照射剂量", value: ["2", 65, 100, 200] },
              { name: "照射剂量", value: ["3", 33, 100, 200] },
              { name: "照射剂量", value: ["4", 17, 100, 200] },
              { name: "照射剂量", value: ["5", 99, 100, 200] }
            ]
          }
        ]
      };
      echartsDiv.setOption(option);
    },
    //设置折线统计图option
    setInitLineOption(echartsLine) {
      var base = +new Date(1968, 9, 3);
      var oneDay = 24 * 3600 * 1000;
      var date = [];
      let option;
      var data = [Math.random() * 300];

      for (var i = 1; i < 20000; i++) {
        var now = new Date((base += oneDay));
        date.push(
          [now.getFullYear(), now.getMonth() + 1, now.getDate()].join("/")
        );
        data.push(Math.round((Math.random() - 0.5) * 20 + data[i - 1]));
      }
      option = {
        tooltip: {
          trigger: "axis",
          position: function(pt) {
            return [pt[0], "10%"];
          }
        },
        title: {
          left: "center",
          text: "病史折线图"
        },
        toolbox: {
          feature: {
            dataZoom: {
              yAxisIndex: "none"
            },
            restore: {},
            saveAsImage: {}
          }
        },
        xAxis: {
          type: "category",
          boundaryGap: false,
          data: date
        },
        yAxis: {
          type: "value",
          boundaryGap: [0, "100%"]
        },
        dataZoom: [
          {
            type: "inside",
            start: 0,
            end: 10
          },
          {
            start: 0,
            end: 10,
            handleIcon:
              "M10.7,11.9v-1.3H9.3v1.3c-4.9,0.3-8.8,4.4-8.8,9.4c0,5,3.9,9.1,8.8,9.4v1.3h1.3v-1.3c4.9-0.3,8.8-4.4,8.8-9.4C19.5,16.3,15.6,12.2,10.7,11.9z M13.3,24.4H6.7V23h6.6V24.4z M13.3,19.6H6.7v-1.4h6.6V19.6z",
            handleSize: "80%",
            handleStyle: {
              color: "#fff",
              shadowBlur: 3,
              shadowColor: "rgba(0, 0, 0, 0.6)",
              shadowOffsetX: 2,
              shadowOffsetY: 2
            }
          }
        ],
        series: [
          {
            name: "模拟数据",
            type: "line",
            smooth: true,
            symbol: "none",
            sampling: "average",
            itemStyle: {
              color: "rgb(255, 70, 131)"
            },
            areaStyle: {
              color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
                {
                  offset: 0,
                  color: "rgb(255, 158, 68)"
                },
                {
                  offset: 1,
                  color: "rgb(255, 70, 131)"
                }
              ])
            },
            data: data
          }
        ]
      };
      echartsLine.setOption(option);
    },
    addCase() {},
    xfzqtys() {
      //下发知情同意书
    },
    addPlanByDoctor() {
      let self = this;
      api.addPlanByDoctor(self.dialogBodyCheckList.providerNo).then(res => {
        this.$message("ok", "成功");
      });
    },
    submitBodyCheckDialog() {
      /**提交检验信息 */
      let self = this;
      let data = {
        proName: self.dialogBodyCheckList.proName,
        sampleNums: self.dialogBodyCheckList.sampleNums,
        providerNo: self.dialogBodyCheckList.providerNo
      };
      self.$refs.bodyCheckForm.validate(valid => {
        if (!valid) {
          return;
        }
        api.addBodyCheckInfo(data).then(res => {
          self.dialog4.isShow = false;
          self.getBodyCheckData();
        });
      });
    },
    getBodyCheckData() {
      let self = this;
      api.queryBodyCheckData(self.dialogBodyCheckList.providerNo).then(res => {
        self.bodyCheckData = res.content;
      });
    },
    queryhTreatmentBodycheckByHid(){
      let self = this;
      api.queryhTreatmentBodycheckByHid(self.hid).then(res=>{
          self.hTreatmentBodycheck = res.content;
      });
    },
    queryhTreatmentBodycheckHistoryByHid(){
      let self = this;
      api.queryhTreatmentBodycheckHistoryByHid(self.providerId).then(res=>{
                  self.tableHistoryData = res.content;
      });
    },
    queryOutsideCheckByHid(){
      let self = this;
      api.queryOutsideCheckByHid(self.hid).then(res=>{
          self.tableOuterCaseData = res.content;
      });
    },
    queryOutsideCheckHistoryByHid(){
      let self = this;
      api.queryOutsideCheckHistoryByHid(self.providerId).then(res=>{
          self.tableOuterCaseHistoryData = res.content;
      });
    }, 
    queryhTreatmentRecordBodycheckByHid(){
      let self = this;
      getCacheTodayCase(self.hid).then(res=>{
        self.todayCaseObj=res.content;
      })
    },
    queryhTreatmentRecordBodycheckHistoryByHid(){
      let self = this;
      api.queryhTreatmentRecordBodycheckHistoryByHid(self.providerId).then(res=>{
          self.tablehTreatmentRecordHistoryData = res.content;
      });
    },
    //新增实验室检验数据
    insertJy() {
      let self = this;
      self.dialog4.isShow = true;
      self.dialog4.title = "新增";
    },
    getData() {
      //获取接诊记录列表
      let self = this;
      self.loading = true;
      let list = {
        name: self.search.name,
        cardId: self.search.cardid,
        pageSize: self.pagination.pageSize,
        currentPage: self.pagination.currentPage,
        status: self.search.currentStatus,
        startTime: null,
        endTime: null

        
      };
      if (self.search.time.length > 0) {
        list.startTime = self.timestampToTime(
          self.search.time[0],
          "yy-mm-dd"
        );
        list.endTime = self.timestampToTime(
          self.search.time[1],
          "yy-mm-dd"
        );
      }
      api.queryTreatments(list).then(
        res => {
          self.tableData = res.content.records;
          self.loading = false;
          self.pagination.total = res.content.total;
        },
        error => {
          self.loading = false;
        }
      );
    },
    /**新版页面数据功能补全 __by:zf */
    getDoctorData() {
      //获取医生列表
      let self = this;
      self.loading = true;
      api.getDoctorData({ id: 4 }).then(
        res => {
          self.dictorData = res.content;
          self.loading = false;
          /**↓ 此处联动 self.updateDialog 方法 Number转换 如果该血源没有医生，则默认所有医生列表中的第一个 ↓*/
          if (self.dialogList.bodyCheckWorker == 0) {
            console.log(self.dialogList.bodyCheckWorker == 0);
            self.dialogList.bodyCheckWorker = self.dictorData[0].id;
          }
        },
        error => {
          self.loading = false;
        }
      );
    },
    submitDialog() {
      /** 更新后台信息*/
      let self = this;
      self.loading = true;
      api.addUpdataCheckBodyInfo(self.dialogList).then(
        res => {
          self.loading = false;
          self.dialog.isShow = false;
          self.$message.success("信息编辑成功！");
          self.getData();
          self.dialog1.isShow = false;
        },
        error => {
          self.loading = false;
        }
      );
    },
    searchData() {
      /**搜索提交 */
      this.pagination.currentPage = 1;
      this.getData();
    },
    updateDialog(row) {
      /**点击编辑*/
      let self = this;
      self.dialog.title = "详情信息";
      self.activeName = "1";
      self.dialog.isShow = true;
      self.dialogList = row;
      self.idCard = row.providerInfo.idNo;
      self.registerNo =  row.registerNo;
      self.bodyRecodeId =  row.bodyRecodeId;
      self.hid = row.id;
      self.baseInfo.sex = row.providerInfo.sex;
      self.queryWeight();
      self.providerId =  row.providerInfo.id;
      self.dialogBodyCheckList.providerNo = row.providerInfo.id;
      self.idCardPhotoUrl1 = api.idImgUpload(row.providerInfo.id, 1);
      self.idCardPhotoUrl2 = api.idImgUpload(row.providerInfo.id, 2);
      self.$nextTick(() => {
        this.initLine();
      });
      self.getBodyCheckData();
      self.dialogList.bodyCheckWorker = Number(self.dialogList.bodyCheckWorker);
      self.getDoctorData();
    },
    //根据体检注册号获取客户基本数据
    queryWeight(){
      let self = this;
      api.queryWeight(self.registerNo).then(res=>{
        self.baseInfo.weight = res.content.weight;
        // self.$message(self.baseInfo.weight +"");
      });
    },
    handleSizeChange(size) {
      /**改变分页条数 */
      this.pagination.currentPage = 1;
      this.pagination.pageSize = size;
      this.getData();
    },
    handleCurrentChange(current) {
      /**改变分页页码 */
      this.pagination.currentPage = current;
      this.getData();
    },
    beforeAvatarUpload(file) {
      /**图标上传前尺寸大小判断 */
      const isJPG = file.type.substr(0, 5) === "image";
      const isLt1M = file.size / 1024 / 1024 < 1;
      if (!isJPG) {
        this.$message.error("只能上传图片!");
      }
      if (!isLt1M) {
        this.$message.error("上传头像图片大小不能超过 1MB!");
      }
      return isJPG && isLt1M;
    },
    handleAvatarSuccess(res, file, fileList) {
      let self = this;
      api.queryImgBase64Data({ sfxPath: res.content }).then(res => {
        self.dialogList.idCardPhoto = res.content;
      });
    },
    handleAvatarSuccess1(res, file, fileList) {
      let self = this;
      api.queryImgBase64Data({ sfxPath: res.content }).then(res => {
        self.dialogList.idCardPhoto1 = res.content;
      });
    },
    callToWz(id){
      let self = this;
      api.callToWz(id).then(res => {
        self.$message("叫号成功...");
        self.getData();
        
      });
    },
    getDataFromChild(val){
      let self = this;
      self.planTableData = val;
    },
    showCourseDisease(row){
      this.courseDiseaseDialog.title='病程'
      this.courseDiseaseDialog.open=true;
      this.courseDiseaseDialog.pid=row.id;
      this.$refs.courseDisease.getDataList();
    },
    showCase(row){
      this.caseDialog.open=true
      this.caseDialog.formdata=row
      this.caseDialog.title="病历"
    }
  },


};
</script>
<style lang="stylus" scoped>
ul {
  list-style: none;
}
input {
  width: 99%;
  height: 39px;
  border: 1px solid rgba(0, 0, 0, 0.5);
  text-align: center;
  line-height: 40px;
  font-size: 20px;
  font-weight: bolder;
  background: white;
  color: red;
}

.createTop {
  width: 90%;
  height: 100%;
  margin: 0 auto;
}

.fontcolors {
  color: red;
}

.createLi {
  display: inline;
  line-height: 40px;
  width: 10.61%;
  float: left;
  border: 1px solid rgba(0, 0, 0, 0.5);
  text-align: center;
  font-size: 20px;
  font-weight: bolder;
  padding: 1px;
}

.fontSet {
  width: 100%;
  height: 76px;
  text-align: center;
  line-height: 76px;
  font-size: 20px;
  font-weight: bolder;
}

.marginCenter {
  margin: 0 auto;
  margin-top:10px;
}

.divBase {
  width: 100%;
  height: 300px;
  border: 1px solid red;
}

.showDataLi {
  width: 400px;
  height: 200px;
  border: 1px solid rgba(0, 0, 0, 0.1);
  background: white;
  box-shadow: 0px 0px 8px rgba(216, 216, 216, 0.9);
  float: left;
  margin-left: 10px;
  margin-top: 10px;
  border-radius: 10px;
  overflow-y: hidden;
  cursor: pointer;

}

.showDataLi:hover {
  border: 1px solid rgba(0, 0, 0, 0.2);
  box-shadow: 0px 0px 13px rgba(0, 0, 0, 0.3);
}

.showDataTop {
  width: 398px;
  height: 148px;
}

.showDataFoot {
  border-top: 1px solid rgba(216, 216, 216, 0.5);
  width: 100%;
  height: 51px;
  text-align: center;
  line-height: 50px;
  background: #F9FAFC;
  font-size: 14px;
  color: black;
}

.showDataFootLeft, .showDataFootRight {
  width: 50%;
  height: 51px;
  color: black;
  float: left;
  margin-left: 0px;
} 

.showDataFootLeft:hover, .showDataFootRight:hover {
  color: #03BC89;
  background: rgba(216, 216, 216, 0.4);
  font-weight: bolder;
}

.showDataFoot:hover {
    color: $theme-color;
    background: rgba(216, 216, 216, 0.4);
    font-weight: bolder;
}

.showDataTopLeft {
  border: 0px solid blue;
  width: 80px;
  height: 82px;
  float: left;
  margin-left: 10px;
  margin-top: 20px;
  border-radius: 42px;
  overflow-y: hidden;
}

.showDataImg {
  width: 100%;
  margin-top: -2px;
}

.showDataTopCenter {
  width: 210px;
  height: 100px;
  float: left;
  margin-left: 10px;
  margin-top: 20px;
}

.showDataTopRight {
  width: 80px;
  height: 148px;
  float: left;
  text-align: center;
}

.divTop {
  width: 100%;
}

.divfooter {
  width: 60%;
  height: 50px;
  margin-top:30px;
}
.statusGreen{
  width:50px;
  height:18px;
  font-size:10px;
  line-height:18px;
  color:white;
  background:#03BC89;
  margin:0px auto;
  margin-top:20px;
  border-radius: 10px;
}
.statusGray{
  width:50px;
  height:18px;
  font-size:10px;
  color:white;
  background:#B7B7B7;
  margin:0px auto;
  margin-top:20px;
  border-radius: 10px;
  line-height:18px;
}

</style>